<?php

namespace frontend\modules\marketing\models;

use Yii;

/**
 * This is the model class for table "coupon_order".
 *
 * @property string $coupon_order_id
 * @property string $order_id
 * @property string $coupon_id
 * @property string $coupon_user_id
 */
class CouponOrder extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'coupon_order';
    }

    /**
     * @inheritdoc
     */
    public function behaviors()
    {
        return [
//            TimestampBehavior::className(),
            // 名为myBehavior4的行为，也是给出了MyBehavior类的配置数组
            'uuid' => [
                'class' => \common\behavior\uuidBehavior::className(),
                'owner' => $this
            ]
        ];
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            ['coupon_order_id','default','value'=>$this->getUUID()],
            [['coupon_order_id', 'order_id', 'coupon_id','coupon_user_id'], 'required'],
            [['coupon_order_id', 'order_id', 'coupon_id'], 'string', 'max' => 40],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'coupon_order_id' => Yii::t('app', 'Coupon Order ID'),
            'order_id' => Yii::t('app', 'Order ID'),
            'coupon_id' => Yii::t('app', 'Coupon ID'),
        ];
    }

    /**
     * @inheritdoc
     * @return \frontend\modules\marketing\models\query\CouponOrderQuery the active query used by this AR class.
     */
    public static function find()
    {
        return new \frontend\modules\marketing\models\query\CouponOrderQuery(get_called_class());
    }
}
